/*
 * @Author: TT-hzy
 * @Date: 2024-07-23 14:58:10
 * @LastEditors: TT-hzy
 * @LastEditTime: 2024-08-06 14:24:34
 */
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'

//配置路径别名
import path from 'path'
const pathSrc = path.resolve(__dirname, 'src')
//自动导入插件
import AutoImport from 'unplugin-auto-import/vite'
import UnoCSS from 'unocss/vite'
export default async () => {
    return defineConfig({
        plugins: [
            uni(),
            UnoCSS(),
            AutoImport({
                imports: ['vue', 'vue-router'],
                dts: 'src/types/auto-imports.d.ts',
            }),
        ],

        resolve: {
            alias: {
                '@': pathSrc,
            },
            extensions: ['.js', '.ts', '.vue', '.json', '.less', '.css'],
            dedupe: ['vue', 'vue-router'],
        },

        css: {
            preprocessorOptions: {
                scss: {
                    prependData: `@import "~@/static/styles/index.scss";`,
                },
            },
        },
        build: {
            // 删除输出
            minify: 'terser',
            terserOptions: {
                compress: {
                    drop_console: true,
                    pure_funcs: ['console.log'],
                },
            },
        },
    })
}
